const formatTime=function() {
  var date = new Date();
  var seperator1 = "-";
  var year = date.getFullYear();
  var month = date.getMonth() + 1;
  var strDate = date.getDate();
  if (month >= 1 && month <= 9) {
    month = "0" + month;
  }
  if (strDate >= 0 && strDate <= 9) {
    strDate = "0" + strDate;
  }
  var currentdate = year + seperator1 + month + seperator1 + strDate;
  return currentdate;
}
const stringslice = n=>{
  return n.slice(0,n)
}
const formatNumber = n => {
    n = n.toString()
    return n[1] ?
        n :
        '0' + n
}
const getData=function(){
  var myDate = new Date();
  let n=myDate.getFullYear();    //获取完整的年份(4位,1970-????)
  let y=myDate.getMonth()+1;       //获取当前月份(0-11,0代表1月)
  let r=myDate.getDate();        //获取当前日(1-31)
  return n+'年'+y+'月'+r+'日'
}
const hs = function(setp){
  return number(setp * 0.75);
}
var usermm = function(setp) {
    if (setp > 0 && setp < 2999) {
        return '1'
    }
    if (setp > 3000 && setp < 3999) {
        return '2'
    }
    if (setp > 4000 && setp < 4999) {
        return '3'
    }
    if (setp > 5000 && setp < 5999) {
        return '4'
    }
    if (setp > 6000) {
        return '5'
    }
}
var showSuccess = text => {
    wx.showToast({ title: text, icon: 'success' })
}
var showError = text => {
    wx.showToast({ title: text, icon: 'success' })
}
var showLogin = text => {
    wx.showToast({ title: text, icon: 'loading' })
}
var stepzh = function(text) {
    var m = text * 0.75;
    return m.toFixed(2);
}
var downImg = function(urls) {
    wx.downloadFile({
        url: urls,
        success: function(imgmess) {
          return imgmess.tempFilePath
        }
    })
}
var xhxx = function(context, arrays, w1, w2, w3, w4, w5, mh) {
    if (arrays == w1) {
        context.drawImage('/image/xx.png', 120, mh, 25, 25);
        context.drawImage('/image/xx1.png', 145, mh, 25, 25);
        context.drawImage('/image/xx1.png', 170, mh, 25, 25);
        context.drawImage('/image/xx1.png', 195, mh, 25, 25);
        context.drawImage('/image/xx1.png', 220, mh, 25, 25);
    }
    if (arrays == w2) {
        context.drawImage('/image/xx.png', 120, mh, 25, 25);
        context.drawImage('/image/xx.png', 145, mh, 25, 25);
        context.drawImage('/image/xx1.png', 170, mh, 25, 25);
        context.drawImage('/image/xx1.png', 195, mh, 25, 25);
        context.drawImage('/image/xx1.png', 220, mh, 25, 25);
    }
    if (arrays == w3) {
        context.drawImage('/image/xx.png', 120, mh, 25, 25);
        context.drawImage('/image/xx.png', 145, mh, 25, 25);
        context.drawImage('/image/xx.png', 170, mh, 25, 25);
        context.drawImage('/image/xx1.png', 195, mh, 25, 25);
        context.drawImage('/image/xx1.png', 220, mh, 25, 25);
    }
    if (arrays == w4) {
        context.drawImage('/image/xx.png', 120, mh, 25, 25);
        context.drawImage('/image/xx.png', 145, mh, 25, 25);
        context.drawImage('/image/xx.png', 170, mh, 25, 25);
        context.drawImage('/image/xx.png', 195, mh, 25, 25);
        context.drawImage('/image/xx1.png', 220, mh, 25, 25);
    }
    if (arrays == w5) {
        context.drawImage('/image/xx.png', 120, mh, 25, 25);
        context.drawImage('/image/xx.png', 145, mh, 25, 25);
        context.drawImage('/image/xx.png', 170, mh, 25, 25);
        context.drawImage('/image/xx.png', 195, mh, 25, 25);
        context.drawImage('/image/xx.png', 220, mh, 25, 25);
    }
}

module.exports = {
    formatTime,
    showSuccess,
    showError,
    showLogin,
    xhxx,
    usermm,
    downImg,
  getData,
  hs,
  stepzh,
  stringslice
}